package com.example.shardingspheredemo.algorithm.standard;

import org.apache.shardingsphere.api.sharding.standard.RangeShardingAlgorithm;
import org.apache.shardingsphere.api.sharding.standard.RangeShardingValue;

import java.util.Arrays;
import java.util.Collection;

/**
 * 数据库的范围查找分片
 */
public class MyRangeDSShardingAlgorithm implements RangeShardingAlgorithm {
	@Override
	public Collection<String> doSharding(Collection collection, RangeShardingValue rangeShardingValue) {

		Long lower = (Long) rangeShardingValue.getValueRange().lowerEndpoint();
		Long upper = (Long) rangeShardingValue.getValueRange().upperEndpoint();

		return Arrays.asList("m1", "m2");
	}
}
